<template>
	<!-- 用户订单查询 -->
	<view class="packOrder">
		<view class="selectOrderList-date">
			<text class="time">{{resultData.start}}</text>
			<text class="centerText">至</text>
			<text class="time">{{resultData.end}}</text>
		</view>
		<none v-if="resultData.list.length==0"></none>
		<view class="selectOrderList-main" v-else>
			<view class="resultData-content" v-for="(item,index) in resultData.list" :key="index" @tap="todetail(item.id)">
				<view class="addressinfo">
					<view class="address-text">
						<view class="addressinfo-title">上门地址</view>
						<view class="text">{{item.location}}{{item.detail}}</view>
					</view>
					<view class="icon iconfont icon-xiangyoujiantou"></view>
				</view>
				<view class="addressinfo appoint-time ">
					<view class="address-text">
						<view class="addressinfo-title">预约时间</view>
						<view class="text">{{item.reservetime}}</view>
					</view>
				</view>
				<view class="addressinfo end-time">
					<view class="address-text">
						<view class="addressinfo-title">完成时间</view>
						<view class="text">{{item.finishtime}}</view>
					</view>
				</view>
			</view>
			<nomore v-if="!hasMore"></nomore>
			<view v-else class="loading">加载中...</view>
		</view>
	</view>
</template>

<script>
	import util from '../../component/commen/api/util';
	import none from "@/otherPages/none/none.vue"
	import nomore from "@/component/noMore.vue"
	export default {
		components: {
			none,
			nomore
		},
		data() {
			return {
				type: "",
				startDate: "", //开始日期
				endDate: "", //结束日期
				resultData: { //查询结果
					list: []
				},
				page:1,//页
				psize:5,//每页条数
				hasMore:true,//是否还有更多数据
				list:[],
			};
		},
		onLoad(e) {
			this.type = e.type
			this.startDate = e.startDate
			this.endDate = e.endDate
		},
		onShow() {
			this.getQuerydata()
		},
		onReachBottom() {
			this.page++
			this.getQuerydata()
			console.log("触底加载")
		},
		methods: {
			getQuerydata() { //获取查询结果
				var params = {
					do: "collector",
					op: "reserveSearch",
					collectorid: uni.getStorageSync("collectorid"),
					type: this.type,
					start: this.startDate,
					end: this.endDate,
					page: this.page,
					psize: this.psize,
				}
				util.requestWithSign(params).then(res => {
					console.log("查询到的结果", res)
					this.resultData = res.data
					this.list = this.list.concat(res.data.list)
					this.resultData.list = this.list
					if(res.data.total==this.resultData.list.length){//数据已经加载完
						return this.hasMore = false
					}
				})
			},
			todetail(value){//点击进入回收详情
				console.log(value)
				uni.navigateTo({
					url: `/otherPages/recoverDetail/recoverDetail?orderId=2&orderDetailId=${value}`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.packOrder {
		.selectOrderList-date {
			text-align: center;
			padding: 30rpx 0;
			box-sizing: border-box;

			.time {
				color: #00b388;

			}

			.centerText {
				display: inline-block;
				margin: 0 20rpx;
				color: #818181;
			}
		}

		.selectOrderList-main {
			padding: 20rpx;
			border-radius: 20rpx;

			.resultData-content {
				margin-top: 20rpx;
			}

			.addressinfo {
				padding: 20rpx;
				background: #fff;
				border-radius: 20rpx 20rpx 0 0;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.address-text {
					display: flex;
					width: 80%;

					.addressinfo-title {
						width: 160rpx;
						font-size: 25rpx;
						color: #6c6c6c;
						// border: 1px solid #4fc3a5;
					}

					.text {
						font-size: 28rpx;
						margin-left: 20rpx;
					}

				}

				.icon-xiangyoujiantou {
					// flex:1;
					margin-left: auto;
				}
			}

			.end-time {
				border-radius: 0;
				border-radius: 0 0 20rpx 20rpx;

				.text {
					color: #818181;
				}
			}

			.appoint-time {
				border-bottom: 2rpx solid #f6f6f6;
			}
		}
	}
</style>